home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / circuits / spice2g6.z / spice2g6 / spice / Fortran / spice.f < prev    next >
Encoding:
Text File  |  1989-02-03  |  11.8 KB  |  333 lines

  1. c spice version 2g.6  sccsid=root.ma 3/15/83
  2.       program spice
  3. c...  cray notes:
  4. c.. change data filnam to 5lspice
  5. c.. change call overlay .. remove last zero
  6. c.. change ??????program to subroutine in all but this overlay
  7. c.. delete overlay spice,0,0 card below
  8. c..
  9.       implicit double precision (a-h,o-z)
  10. c
  11. c
  12. c spice version 2g.6  sccsid=root.ma 3/15/83
  13. c
  14. c     spice is an electronic circuit simulation program that was deve-
  15. c loped by the integrated circuits group of the electronics research
  16. c laboratory and the department of electrical engineering and computer
  17. c sciences at the university of california, berkeley, california.  the
  18. c program spice is available free of charge to any interested party.
  19. c the sale, resale, or use of this program for profit without the
  20. c express written consent of the department of electrical engineering
  21. c and computer sciences, university of california, berkeley, california,
  22. c is forbidden.
  23. c
  24. c
  25. c     the present version is based on the spice2 program versions 2e.3
  26. c and 2f.1 developed at the university of california berkeley and the
  27. c hewlett-packard spice version 2.7.
  28. c     this version is designed to be transportable on most computers
  29. c with an ansi fortran compiler and enough memory space for code and
  30. c data. the memory manager uses the function 'locf' to find the
  31. c address of a pointer; this function must be provided.
  32. c
  33. c
  34. c implementation notes:
  35. c
  36. c     subroutines mclock and mdate return the time (as hh:mm:ss) and
  37. c the date (as dd mmm yy), respectively.  subroutine getcje returns in
  38. c common block /cje/ various attributes of the current job environment.
  39. c spice expects getcje to set /cje/ variables maxtim, itime, and icost.
  40. c maxtim is the maximum cpu time in seconds, itime is the elapsed cpu
  41. c time in seconds, and icost is the job cost in cents.
  42. c subroutine memory is used to change the number of memory words
  43. c allocated to spice.  if the amount of memory allocated to a jobstep
  44. c is fixed, subroutine memory need not be changed.
  45. c     subroutine second(t) returns the time in seconds and is used
  46. c for timing purposes. it must be provided where not available.
  47. c     ifamwa (set in a data statement below) should be set to the
  48. c address of the first available word of memory (following overlays, if
  49. c any).  the proper value should be easily obtainable from any load map.
  50. c ifamwa is used only on computers where the program (spice) can change
  51. c the allocated memory dynamically at run time according to circuit size.
  52. c (see also comments under subroutine setmem).
  53. c     all berkeley spice2.f release versions do not implement the ifamwa
  54. c feature due to its dependence on operating system.
  55. c     with the exception of most flags, all data in spice are stored in
  56. c the form of managed tables allocated in the /blank/ array value().
  57. c array value() can be redimensioned in the main program according to
  58. c memory availability at each user site. it should be noted again that
  59. c the program dynamically manages its data within the bounds of array
  60. c value().
  61. c     the vax release versions assume the virtual memory feature and
  62. c dimension value() to 200,000 double precision words.
  63. c     the cdc and ibm versions dimension value() to 20000 real or
  64. c real*8 words, respectively.
  65. c     spice is particularly well-suited to being run using a one-level
  66. c overlay structure beginning with routines spice (the overlay root),
  67. c readin, errchk, setup, dctran, dcop, acan, and ovtpvt.  the order of
  68. c the routines in this listing corresponds to that structure.  note
  69. c that if cdc explicit overlaying is to be used, an overlay directive
  70. c card must be inserted before the first line of each of the just-named
  71. c routines.
  72. c
  73. c
  74. c spice version 2g.6  sccsid=tabinf 3/15/83
  75.       common /tabinf/ ielmnt,isbckt,nsbckt,iunsat,nunsat,itemps,numtem,
  76.      1   isens,nsens,ifour,nfour,ifield,icode,idelim,icolum,insize,
  77.      2   junode,lsbkpt,numbkp,iorder,jmnode,iur,iuc,ilc,ilr,numoff,isr,
  78.      3   nmoffc,iseq,iseq1,neqn,nodevs,ndiag,iswap,iequa,macins,lvnim1,
  79.      4   lx0,lvn,lynl,lyu,lyl,lx1,lx2,lx3,lx4,lx5,lx6,lx7,ld0,ld1,ltd,
  80.      5   imynl,imvn,lcvn,nsnod,nsmat,nsval,icnod,icmat,icval,
  81.      6   loutpt,lpol,lzer,irswpf,irswpr,icswpf,icswpr,irpt,jcpt,
  82.      7   irowno,jcolno,nttbr,nttar,lvntmp
  83. c spice version 2g.6  sccsid=miscel 3/15/83
  84.       common /miscel/ atime,aprog(3),adate,atitle(10),defl,defw,defad,
  85.      1  defas,rstats(50),iwidth,lwidth,nopage
  86. c spice version 2g.6  sccsid=line 3/15/83
  87.       common /line/ achar,afield(15),oldlin(15),kntrc,kntlim
  88. c spice version 2g.6  sccsid=cirdat 3/15/83
  89.       common /cirdat/ locate(50),jelcnt(50),nunods,ncnods,numnod,nstop,
  90.      1   nut,nlt,nxtrm,ndist,ntlin,ibr,numvs,numalt,numcyc
  91. c spice version 2g.6  sccsid=mosarg 3/15/83
  92.       common /mosarg/ vto,beta,gamma,phi,phib,cox,xnsub,xnfs,xd,xj,xld,
  93.      1   xlamda,uo,uexp,vbp,utra,vmax,xneff,xl,xw,vbi,von,vdsat,qspof,
  94.      2   beta0,beta1,cdrain,xqco,xqc,fnarrw,fshort,lev
  95. c spice version 2g.6  sccsid=status 3/15/83
  96.       common /status/ omega,time,delta,delold(7),ag(7),vt,xni,egfet,
  97.      1   xmu,sfactr,mode,modedc,icalc,initf,method,iord,maxord,noncon,
  98.      2   iterno,itemno,nosolv,modac,ipiv,ivmflg,ipostp,iscrch,iofile
  99. c spice version 2g.6  sccsid=flags 3/15/83
  100.       common /flags/ iprnta,iprntl,iprntm,iprntn,iprnto,limtim,limpts,
  101.      1   lvlcod,lvltim,itl1,itl2,itl3,itl4,itl5,itl6,igoof,nogo,keof
  102. c spice version 2g.6  sccsid=knstnt 3/15/83
  103.       common /knstnt/ twopi,xlog2,xlog10,root2,rad,boltz,charge,ctok,
  104.      1   gmin,reltol,abstol,vntol,trtol,chgtol,eps0,epssil,epsox,
  105.      2   pivtol,pivrel
  106. c spice version 2g.6  sccsid=memmgr 3/15/83
  107.       common /memmgr/ cpyknt,istack(1),lorg,icore,maxcor,maxuse,memavl,
  108.      1   ldval,numblk,loctab,ltab,ifwa,nwoff,ntab,maxmem,memerr,nwd4,
  109.      2   nwd8,nwd16
  110. c spice version 2g.6  sccsid=dc 3/15/83
  111.       common /dc/ tcstar(2),tcstop(2),tcincr(2),icvflg,itcelm(2),kssop,
  112.      1   kinel,kidin,kovar,kidout
  113. c spice version 2g.6  sccsid=ac 3/15/83
  114.       common /ac/ fstart,fstop,fincr,skw2,refprl,spw2,jacflg,idfreq,
  115.      1   inoise,nosprt,nosout,nosin,idist,idprt
  116. c spice version 2g.6  sccsid=tran 3/15/83
  117.       common /tran/ tstep,tstop,tstart,delmax,tdmax,forfre,jtrflg
  118. c spice version 2g.6  sccsid=outinf 3/15/83
  119.       common /outinf/ xincr,string(15),xstart,yvar(8),itab(8),itype(8),
  120.      1   ilogy(8),npoint,numout,kntr,numdgt
  121. c spice version 2g.6  sccsid=cje 3/15/83
  122.       common /cje/ maxtim,itime,icost
  123. c spice version 2g.6  sccsid=debug 3/15/83
  124.       common/debug/ idebug(20)
  125. c spice version 2g.6  sccsid=blank 3/15/83
  126.       common /blank/ value(200000)
  127.       integer nodplc(64)
  128.       complex cvalue(32)
  129.       equivalence (value(1),nodplc(1),cvalue(1))
  130. c
  131. c
  132. c
  133.       dimension acctit(4)
  134.       dimension remain(4)
  135.       data ablnk /1h  /
  136.       data acctit / 8hjob stat, 8histics s, 8hummary  , 8h         /
  137.       data ahdr1,ahdr2,ahdr3 / 8h  spice ,8h2g.6    ,8h3/15/83     /
  138. c
  139. c
  140.       ipostp=0
  141. c     check if a raw data file should be written
  142. c     open file if so required
  143.       if  (iargc().gt.0) ipostp=iopraw()
  144.       maxmem=2*200000
  145.       maxtim=1e8
  146.       icost=0
  147.       iofile=6
  148. c
  149. c  initialization
  150. c
  151.       aprog(1)=ahdr1
  152.       aprog(2)=ahdr2
  153.       aprog(3)=ahdr3
  154.       achar=ablnk
  155.       keof=0
  156.       call xtime(atime)
  157.       call xdate(adate)
  158.       boltz=1.3806226d-23
  159.       charge=1.6021918d-19
  160.       ctok=273.15d0
  161.       eps0=8.854214871d-12
  162.       epssil=11.7d0*eps0
  163.       epsox=3.9d0*eps0
  164.       twopi=8.0d0*datan2(1.0d0,1.0d0)
  165.       rad=360.0d0/twopi
  166.       xlog2=dlog(2.0d0)
  167.       xlog10=dlog(10.0d0)
  168.       root2=dsqrt(2.0d0)
  169.       nodata=1
  170. c
  171. c  begin job
  172. c
  173.    10 if (keof.eq.1) go to 1000
  174.       call getcje
  175.       call second(time1)
  176.       icost1=icost
  177.       igoof=0
  178.       mode=0
  179.       nogo=0
  180.       call setmem(nodplc(1),maxmem)
  181.       if (nogo.ne.0) go to 1000
  182.       call zero8(rstats,50)
  183. c
  184. c  read remainder of data deck and check for input errors
  185. c
  186.       call readin
  187.       if (nogo.ne.0) go to 300
  188.       if (keof.eq.1) go to 1000
  189.       nodata=0
  190.    50 call errchk
  191.       if (nogo.ne.0) go to 300
  192.       call setup
  193.       if (nogo.ne.0) go to 300
  194. c
  195. c  change parameters and re-analisis
  196. c
  197.       if (numcyc.eq.0) go to 90
  198.    70 if (numcyc.ge.numalt) go to 310
  199.       numcyc=numcyc+1
  200.       call alter
  201.       if (nogo.ne.0) go to 305
  202. c
  203. c  cycle through temperatures
  204. c
  205.    90 itemno=1
  206.       if (numtem.eq.1) go to 110
  207.   100 if (itemno.eq.numtem) go to 70
  208.       itemno=itemno+1
  209.       call tmpupd
  210. c
  211. c  dc transfer curves
  212. c
  213.   110 if (icvflg.eq.0) go to 150
  214. c...  see routine *dctran* for explanation of *mode*, etc.
  215.       mode=1
  216.       modedc=3
  217.       call dctran
  218.       call ovtpvt
  219.       if (nogo.ne.0) go to 300
  220. c
  221. c  small signal operating point
  222. c
  223.   150 if (kssop.gt.0) go to 170
  224.       if (jacflg.ne.0) go to 170
  225.       if ((icvflg+jtrflg).gt.0) go to 250
  226.   170 mode=1
  227.       modedc=1
  228.       call dctran
  229.       if (nogo.ne.0) go to 300
  230.       call dcop
  231.       if (nogo.ne.0) go to 300
  232. c
  233. c  ac small signal analysis
  234. c
  235.   200 if (jacflg.eq.0) go to 250
  236.       mode=3
  237.       call acan
  238.       call ovtpvt
  239.       if (nogo.ne.0) go to 300
  240. c
  241. c  transient analysis
  242. c
  243.   250 if (jtrflg.eq.0) go to 100
  244.       mode=1
  245.       modedc=2
  246.       call dctran
  247.       if (nogo.ne.0) go to 300
  248.       call dcop
  249.       if (nogo.ne.0) go to 300
  250.       mode=2
  251.       call dctran
  252.       call ovtpvt
  253.       if (nogo.ne.0) go to 300
  254.       go to 100
  255. c
  256. c  job concluded
  257. c
  258.   300 write (iofile,301)
  259.   301 format(1h0,9x,'***** job aborted')
  260.       nodata=0
  261.       go to 320
  262.   305 write (iofile,306)
  263.   306 format (1h0,9x,'***** this parameter change is illegal')
  264.   310 write (iofile,311)
  265.   311 format(1h0,/,9x,'job concluded')
  266. c
  267. c  job accounting
  268. c
  269.   320 continue
  270.       numel=0
  271.       do 360 i=1,18
  272.   360 numel=numel+jelcnt(i)
  273.       numtem=max0(numtem-1,1)
  274.       idist=min0(idist,1)
  275.       if (iprnta.eq.0) go to 800
  276.       call title(-1,lwidth,1,acctit)
  277.       write (iofile,361) nunods,ncnods,numnod,numel,(jelcnt(i),i=11,14)
  278.   361 format('   nunods ncnods numnod numel  diodes  bjts  jfets  mfets'
  279.      1   //,i9,2i7,i6,i8,i6,2i7)
  280.       write (iofile,371) numtem,icvflg,jtrflg,jacflg,inoise,idist,nogo
  281.   371 format(/'0  numtem icvflg jtrflg jacflg inoise  idist   nogo'/,
  282.      1   2h0 ,7i7)
  283.       write (iofile,381) rstats(20),rstats(21),rstats(22),rstats(23),
  284.      1   rstats(26),rstats(27)
  285.   381 format(/'0  nstop   nttbr   nttar   ifill    iops    perspa'//,
  286.      1   1x,5f8.0,f9.3)
  287.       write (iofile,391) rstats(30),rstats(31),rstats(32),maxmem,maxuse,
  288.      1   cpyknt
  289.   391 format(/'0  numttp  numrtp  numnit  maxmem  memuse  copyknt',//,
  290.      1   2x,3f8.0,2x,i6,2x,i6,2x,f8.0)
  291.       write (iofile,401) (rstats(i),i=1,6),rstats(50),rstats(49),
  292.      1   rstats(46),(rstats(i),i=7,11)
  293.   401 format(/,
  294.      1   1h0,9x,'readin  ',12x,f10.2/,
  295.      2   1h0,9x,'setup   ',12x,f10.2/,
  296.      3   1h0,9x,'trcurv  ',12x,f10.2,10x,f6.0/,
  297.      4   1h0,9x,'dcan    ',12x,f10.2,10x,f6.0/,
  298.      5   1h0,9x,'dcdcmp  ',12x,f10.3,10x,f6.0/,
  299.      6   1h0,9x,'dcsol   ',12x,f10.3/,
  300.      7   1h0,9x,'acan    ',12x,f10.2,10x,f6.0/,
  301.      8   1h0,9x,'tranan  ',12x,f10.2,10x,f6.0/,
  302.      9   1h0,9x,'output  ',12x,f10.2)
  303.       write (iofile,402) rstats(45),rstats(48),rstats(47),rstats(44),
  304.      1   rstats(43)
  305.   402 format(
  306.      1   1h0,9x,'load    ',12x,f10.3/,
  307.      2   1h0,9x,'codgen  ',12x,f10.3,10x,f6.0/,
  308.      3   1h0,9x,'codexc  ',12x,f10.3/,
  309.      4   1h0,9x,'macins  ',12x,f10.3)
  310.   800 call getcje
  311.       call second(time2)
  312.       et=time2-time1
  313.       tcost=dble(icost-icost1)/100.0d0
  314.       if (iprnta.eq.0) go to 810
  315.       ohead=et-(rstats(1)+rstats(2)+rstats(3)+rstats(5)+rstats(7)
  316.      1   +rstats(9)+rstats(11))
  317.       write (iofile,801) ohead
  318.   801 format(1h0,9x,'overhead',12x,f10.2)
  319.   810 write (iofile,811) et
  320.   811 format(1h0,9x,'total job time      ',f10.2)
  321.       rstats(33)=cpyknt
  322.       rstats(34)=et
  323.       rstats(35)=tcost
  324.       rstats(36)=ohead
  325.   900 if ((maxtim-itime).ge.limtim) go to 10
  326.       write (iofile,901)
  327.   901 format('1warning:  further analysis stopped due to cpu time limit'
  328.      1/)
  329.  1000 if(nodata.ne.0) write(iofile,1001)
  330.  1001 format(/1x,'input deck (file) contains no data.')
  331.       stop
  332.       end
  333.